package com.sakura.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sakura.dto.QueryCheckProjectDTO;
import com.sakura.entity.CheckProject;
import com.sakura.service.CheckProjectService;
import com.sakura.mapper.CheckProjectMapper;
import org.springframework.stereotype.Service;

/**
* @author Sakura
* @description 针对表【check_project】的数据库操作Service实现
* @createDate 2023-11-22 15:49:03
*/
@Service
public class CheckProjectServiceImpl extends ServiceImpl<CheckProjectMapper, CheckProject>
    implements CheckProjectService{

    @Override
    public Object getPage(QueryCheckProjectDTO queryCheckProjectDTO) {
        LambdaQueryWrapper<CheckProject> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(queryCheckProjectDTO.getId() != null && queryCheckProjectDTO.getId() != 0,
                        CheckProject::getId, queryCheckProjectDTO.getId())
                .like(queryCheckProjectDTO.getName() != null && !"".equals(queryCheckProjectDTO.getName()),
                        CheckProject::getName, queryCheckProjectDTO.getName());

        Page<CheckProject> page = this.page(new Page<>(queryCheckProjectDTO.getCurrent(), queryCheckProjectDTO.getPageSize()), queryWrapper);
        return page;
    }
}




